<script setup>
import { ref , watch, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
import {
  Message,
  Check,
  ArrowRight,
  CircleCheck,
  CirclePlus,
  CirclePlusFilled,
  Plus,
} from '@element-plus/icons-vue'
const breadcrumbList = ref([])
const initBreadcrumbList = () => {
  breadcrumbList.value = route.matched
}
onMounted(() => {
  initBreadcrumbList()
})
watch(route, () => {
      initBreadcrumbList()
    }, {
  immediate: true,
  deep: true
})
const handlerToPersonal = () => {
  router.push('/personal')
}
const handlerLogout = () => {
  router.push('/login')
}
</script>
<template>
  <el-card>
  <el-page-header icon="Message" class="layout-header" title="Clubs">
    <template #content>
      <el-breadcrumb :separator-icon="ArrowRight">
        <el-breadcrumb-item :to="{ path: '/' }">homepage</el-breadcrumb-item>
        <el-breadcrumb-item :to="item.path" v-for="(item, index) in breadcrumbList">{{ item.meta.title }}</el-breadcrumb-item>
      </el-breadcrumb>
    </template>
    <template #extra>
      <div class="items-center">
        <el-badge :value="12" class="item">
          <el-button>comments</el-button>
        </el-badge>
        <el-badge :value="12" class="item">
          <el-button>comments</el-button>
        </el-badge>
        <el-dropdown>
          <el-avatar
              :size="32"
              class="mr-3"
              src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
          />
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item :icon="Plus" @click="handlerToPersonal">个人主页</el-dropdown-item>
              <el-dropdown-item :icon="CirclePlus" @click="handlerLogout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </template>
  </el-page-header>
  </el-card>
</template>

<style scoped lang="scss">
.block-col-2 .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.block-col-2 .el-dropdown-link {
  display: flex;
  align-items: center;
}
.items-center{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
</style>